//
//  RecTravelNotesDetailsTableViewCell.m
//  TravelEveryDay
//
//  Created by dlios on 15-10-20.
//  Copyright (c) 2015年 com.lanou3g. All rights reserved.
//

#import "RecTravelNotesDetailsTableViewCell.h"

@implementation RecTravelNotesDetailsTableViewCell
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
     
        self.contentView.backgroundColor = [UIColor colorWithRed:251/255. green:246/255. blue:233/255. alpha:1];
        _image = [[UIImageView alloc] initWithFrame:CGRectZero];
        [self.contentView addSubview:_image];
        
        _myTextLabel = [[UILabel alloc] initWithFrame:CGRectZero];
        
        [_myTextLabel setNumberOfLines:0];
        _myTextLabel.font = [UIFont systemFontOfSize:16.];
        [self.contentView addSubview:_myTextLabel];
        
        _heartImage = [[UIImageView alloc] initWithFrame:CGRectMake(260 * WIDTH, _image.frame.size.height - 60 * HEIGHT, 30 * WIDTH, 30 * HEIGHT)];
        [_heartImage setImage:[UIImage imageNamed:@"play-like_13x12_hl@2x.png"]];
        [_image addSubview:_heartImage];
        
        _likeLabel = [[UILabel alloc] initWithFrame:CGRectMake(240 * WIDTH, _image.frame.size.height - 60 * HEIGHT, 30 * WIDTH, 30 * HEIGHT)];
        _likeLabel.textColor = [UIColor colorWithRed:62/255 green:176/255. blue:193/255. alpha:1];
        [_image addSubview:_likeLabel];
        
        _commentLabel = [[UILabel alloc] initWithFrame:CGRectMake(280 * WIDTH, _image.frame.size.height - 60 * HEIGHT, 20 * WIDTH, 30 * HEIGHT)];
        _commentLabel.textColor = [UIColor colorWithRed:62/255 green:176/255. blue:193/255. alpha:1];
        [_image addSubview:_commentLabel];
        
        _commentImage = [[UIImageView alloc] initWithFrame:CGRectZero];
        [_commentImage setImage:[UIImage imageNamed:@"comment.png"]];
        [_image addSubview:_commentImage];
        
        _timeLabel = [[UILabel alloc] initWithFrame:CGRectZero];
        _timeLabel.alpha = 0.6;
        [self.contentView addSubview:_timeLabel];
        _areaLabel = [[UILabel alloc] initWithFrame:CGRectZero];
        _areaLabel.layer.cornerRadius = 10;
        _areaLabel.layer.masksToBounds = YES;
        _areaLabel.textAlignment = NSTextAlignmentCenter;
        _areaLabel.textColor = [UIColor colorWithRed:62/255 green:176/255. blue:193/255. alpha:1];
        _areaLabel.backgroundColor = [UIColor colorWithRed:251/255. green:246/255. blue:233/255. alpha:1];
        [self.contentView addSubview:_areaLabel];

    }
    return self;
}
-(void)getData:(RecTravelNotesDetailsModel *)model
{
    [_image sd_setImageWithURL:[NSURL URLWithString:model.photo] placeholderImage:PLACEHOLDERIMAGE];
    
    _myTextLabel.text = model.text;
    
    _timeLabel.text = [model.local_time substringWithRange:NSMakeRange(0, 16)];
    
    if (![model.province isEqualToString:@""] || ![model.country isEqualToString:@""]) {
        _areaLabel.text = [NSString stringWithFormat:@"%@,%@",model.country,model.province];
    }
    _likeLabel.frame = CGRectMake(240 * WIDTH, _image.frame.size.height - 45 * HEIGHT, 30 * WIDTH, 30 * HEIGHT);
    _heartImage.frame = CGRectMake(270 * WIDTH, _image.frame.size.height - 40 * HEIGHT, 20 * WIDTH, 20 * HEIGHT);
    _commentLabel.frame = CGRectMake(300 * WIDTH, _image.frame.size.height - 45 * HEIGHT, 30 * WIDTH, 30 * HEIGHT);
    _commentImage.frame = CGRectMake(320 * WIDTH, _image.frame.size.height - 40 * HEIGHT, 20 * WIDTH, 20 * HEIGHT);
    _likeLabel.text = model.recommendations.stringValue;
    _commentLabel.text = model.comments.stringValue;
    _areaLabel.frame = CGRectMake(220 * WIDTH, _myTextLabel.frame.size.height + _image.frame.size.height + 10 * HEIGHT, 120 * WIDTH, 40 * HEIGHT);
    _timeLabel.frame = CGRectMake(10 * WIDTH, _myTextLabel.frame.size.height + _image.frame.size.height + 10 * HEIGHT, 200 * WIDTH, 40 * HEIGHT);
//    _view = [[UIView alloc] initWithFrame:CGRectMake(100, 0, 1, _image.frame.size.height + _myTextLabel.frame.size.height)];
    
   

}
- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
